﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;

namespace DALMSSQL
{
    /// <summary>
    /// 提高效率！！！！，线程 公用一个dbsession
    /// </summary>
    public  class DBSessionFactory:IDAL.IDBSessionFactory
    {
        public IDAL.IDBSession GetDBSession()
        {
            //从当前线程中获取 DBSession 数据仓对象
            IDAL.IDBSession dbSession = CallContext.GetData(typeof(DBSessionFactory).Name) as DBSession;
            if (dbSession == null)
            {
                dbSession = new DBSession();
                CallContext.SetData(typeof(DBContextFactory).Name, dbSession);
            }
            return dbSession;
        }
    }
}
